<html>
<head><meta charset="utf-8"><title>Get the cause of a std::Error using failure? · project-error-handling · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/index.html">project-error-handling</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Get.20the.20cause.20of.20a.20std.3A.3AError.20using.20failure.3F.html">Get the cause of a std::Error using failure?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="214725887"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Get%20the%20cause%20of%20a%20std%3A%3AError%20using%20failure%3F/near/214725887" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Get.20the.20cause.20of.20a.20std.3A.3AError.20using.20failure.3F.html#214725887">(Oct 27 2020 at 16:30)</a>:</h4>
<p>Reposting <a href="https://discord.com/channels/273534239310479360/274215136414400513/770684800096665640">https://discord.com/channels/273534239310479360/274215136414400513/770684800096665640</a>:</p>
<p>I'm using <code>failure</code> (I can't switch for reasons, it's a large code base) and I'm also using <code>tera</code>, which uses <code>std::error::Error</code>, not <code>failure::Fail</code>. When I try to look at the causes of an error, it always stops at the outer-most error instead of showing the root cause:</p>
<div class="codehilite"><pre><span></span><code>Error: failed while loading tera templates in &quot;templates&quot;

Caused by:
    Failed to parse &quot;/home/joshua/src/rust/docs.rs/templates/header/package_navigation.html&quot;
</code></pre></div>


<p>Is there a way to get this to show the root cause without switching away from failure?<br>
This is the error itself, so I know it exists, it's just not being shown: <a href="https://docs.rs/tera/1.5.0/src/tera/tera.rs.html#187-L188">https://docs.rs/tera/1.5.0/src/tera/tera.rs.html#187-L188</a><br>
and I'm calling <code>iter_causes</code>: <a href="https://docs.rs/failure/0.1.8/failure/struct.Error.html#method.iter_causes">https://docs.rs/failure/0.1.8/failure/struct.Error.html#method.iter_causes</a></p>



<a name="214729581"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Get%20the%20cause%20of%20a%20std%3A%3AError%20using%20failure%3F/near/214729581" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Get.20the.20cause.20of.20a.20std.3A.3AError.20using.20failure.3F.html#214729581">(Oct 27 2020 at 16:55)</a>:</h4>
<p>I think there was a transition plan for failure</p>



<a name="214729594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Get%20the%20cause%20of%20a%20std%3A%3AError%20using%20failure%3F/near/214729594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Get.20the.20cause.20of.20a.20std.3A.3AError.20using.20failure.3F.html#214729594">(Oct 27 2020 at 16:55)</a>:</h4>
<p>we could theoretically drive that if someone wanted to do the implementation</p>



<a name="214729626"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Get%20the%20cause%20of%20a%20std%3A%3AError%20using%20failure%3F/near/214729626" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Get.20the.20cause.20of.20a.20std.3A.3AError.20using.20failure.3F.html#214729626">(Oct 27 2020 at 16:55)</a>:</h4>
<p>It was sketched out in the original fix the error trait RFC</p>



<a name="214729634"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Get%20the%20cause%20of%20a%20std%3A%3AError%20using%20failure%3F/near/214729634" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Get.20the.20cause.20of.20a.20std.3A.3AError.20using.20failure.3F.html#214729634">(Oct 27 2020 at 16:55)</a>:</h4>
<p>I'd be interested in that</p>



<a name="214729663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Get%20the%20cause%20of%20a%20std%3A%3AError%20using%20failure%3F/near/214729663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Get.20the.20cause.20of.20a.20std.3A.3AError.20using.20failure.3F.html#214729663">(Oct 27 2020 at 16:55)</a>:</h4>
<p>it's not feasible for us to switch from failure until <code>thiserror</code> has backtraces on stable</p>



<a name="214730112"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Get%20the%20cause%20of%20a%20std%3A%3AError%20using%20failure%3F/near/214730112" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Get.20the.20cause.20of.20a.20std.3A.3AError.20using.20failure.3F.html#214730112">(Oct 27 2020 at 16:58)</a>:</h4>
<p>if you don't mind writing your own eyre handler then I can walk you through getting back traces on stable</p>



<a name="214730159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Get%20the%20cause%20of%20a%20std%3A%3AError%20using%20failure%3F/near/214730159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Get.20the.20cause.20of.20a.20std.3A.3AError.20using.20failure.3F.html#214730159">(Oct 27 2020 at 16:59)</a>:</h4>
<p>Not sure which one would be easier honestly</p>



<a name="214730189"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Get%20the%20cause%20of%20a%20std%3A%3AError%20using%20failure%3F/near/214730189" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Get.20the.20cause.20of.20a.20std.3A.3AError.20using.20failure.3F.html#214730189">(Oct 27 2020 at 16:59)</a>:</h4>
<p>if you have to switch off a failure to get it anyways then this might not actually be easier than making a breaking change in failure itself</p>



<a name="214732339"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Get%20the%20cause%20of%20a%20std%3A%3AError%20using%20failure%3F/near/214732339" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Get.20the.20cause.20of.20a.20std.3A.3AError.20using.20failure.3F.html#214732339">(Oct 27 2020 at 17:12)</a>:</h4>
<p>Ooh that would be really cool</p>



<a name="214732393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Get%20the%20cause%20of%20a%20std%3A%3AError%20using%20failure%3F/near/214732393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Get.20the.20cause.20of.20a.20std.3A.3AError.20using.20failure.3F.html#214732393">(Oct 27 2020 at 17:13)</a>:</h4>
<p><span class="user-mention" data-user-id="210267">@Nemo157</span> did most of the work to switch <a href="http://docs.rs">docs.rs</a> but got stuck on backtraces</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>